﻿
MERGE [TagDim] AS target
	USING [tmp_Tags] AS source ON
		(target.TagId = source.TagId)
	WHEN MATCHED THEN
		UPDATE SET
			target.Name = source.Name,
			target.DisplayName = source.DisplayName,
			target.Parent = source.Parent,
			target.Unit = source.Unit
	WHEN NOT MATCHED THEN
		INSERT (TagId, Name, DisplayName, Parent, Unit) VALUES
		(source.TagId, source.Name, source.DisplayName, source.Parent, source.Unit);

DROP TABLE [tmp_Tags];